<template>
  <div class="dashboard-container">
    <full-page ref="fullpage" :options="options" >
      <div class="section" >
        <div class="carousel">
          <el-carousel class="el-carousel" :interval="5000" arrow="always">
            <el-carousel-item v-for="item in imgs" :key="item" style="height: 500px">
              <el-image :src="item" fit="fit" />
            </el-carousel-item>
          </el-carousel>
          <div class="label" v-html="content" />
        </div>
        <div class="search-bar">
          <input v-model="searchInput" type="text" placeholder="输入感兴趣的内容">
          <el-button class="search-bar-button" style="margin-right: 0" type="primary" @click="toSearchPage('job')">找工作</el-button>
          <el-button class="search-bar-button" type="info" @click="toSearchPage('com')">找公司</el-button>
        </div>
        <div class="more">
          <span @click="wander">随便逛逛</span>
          <svg-icon icon-class="bi-arrow-down" class-name="more-icon" @click="wander" />
        </div>

        <div style="display: flex;justify-content: center;align-items: center" />
      </div>
      <div class="section">
        <div class="section-item section-main">
          <span class="more">
            <span class="el-icon-arrow-up" style="font-size: 25px" @click="toSearch" />
            <span @click="toSearch">检索</span>
          </span>

          <div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;width: 80%;margin-top: 20px;height: calc(100vh - 400px);">
            <div class="search-keyword">
              <div class="title">热门工种</div>
              <div style="display: flex;flex-direction: column;align-items: flex-start;justify-content: flex-start;width: 100%">
                <div v-for="(type, tIndex) in positionOption" :key="tIndex" :index="tIndex" style="width: 100%;">
                  <div class="search-keyword-content">
                    <span class="text-primary" style="font-weight: bold;min-width: 80px;padding: 5px">{{ type.name }}:</span>
                    <el-tag v-for="(item, index) in type.children" :key="index" class="tag" @click="toSearchWithParam(type.name, item.name)">
                      {{ item.name }}
                    </el-tag>
                  </div>
                </div>
              </div>
            </div>
            <el-image v-if="ad.url && ad.url.length > 0" style="height: 600px" :src="ad.url" fit="scale-down"  />
            <div v-else class="advertisement text-info">
              <span >广告位招租</span>
            </div>
          </div>
          <div class="more" style="position: absolute;bottom: 100px">
            <span @click="wander">推荐岗位</span>
            <svg-icon icon-class="bi-arrow-down" class-name="more-icon" @click="wander" />
          </div>
        </div>
      </div>
<!--      <div class="section">-->
<!--        <div class="section-item section-main">-->
<!--          <span class="more">-->
<!--            <span class="el-icon-arrow-up" style="font-size: 25px" @click="toSearch" />-->
<!--            <span @click="toSearch">检索</span>-->
<!--          </span>-->
<!--          <div style="width: 40%;"><el-divider><span class="text-primary">推荐岗位</span></el-divider></div>-->

<!--          <div style="display: flex;flex-direction: column;align-items: center;justify-content: flex-start;width: 80%;margin: 20px auto 0;height: calc(100vh - 400px);">-->
<!--            <div class="positions">-->
<!--              <div class="position-item">-->
<!--                <div style="display: flex;flex-direction: row;align-items: center;justify-content: space-between;width: 100%;">-->
<!--                  <div style="display: flex;flex-direction: column;align-items: flex-start;justify-content: flex-start">-->
<!--                    <div class="position-item-name text-primary">-->
<!--                      带薪拉屎-->
<!--                    </div>-->
<!--                    <div class="position-item-detail text-info">-->
<!--                      <span class="position-detail">广州</span> |-->
<!--                      <span class="position-detail">经验不限</span> |-->
<!--                      <span class="position-detail">本科</span>-->
<!--                    </div>-->
<!--                  </div>-->
<!--                  <div style="display: flex;flex-direction: column;align-items: center;justify-content: flex-start" class="text-danger position-item-wage">-->
<!--                    23K - 50K-->
<!--                  </div>-->
<!--                </div>-->
<!--                <div style="width: 99%;margin: 5px auto"><el-divider><span class="text-primary"></span></el-divider></div>-->
<!--                <div class="position-item-com">-->
<!--                  <el-image class="com-icon" src="https://img.bosszhipin.com/beijin/mcs/bar/brand/92025.jpg?x-oss-process=image/resize,w_120,limit_0" />-->
<!--                  <div class="com-name">网易</div>-->
<!--                  <div class="com-detail">互联网</div>-->
<!--                  <div class="com-detail">已上市</div>-->
<!--                  <div class="com-detail">不需要融资</div>-->
<!--                </div>-->
<!--              </div>-->
<!--            </div>-->
<!--          </div>-->
<!--        </div>-->
<!--      </div>-->
    </full-page>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import banner1 from '@/assets/6.jpg'
import banner2 from '@/assets/7.jpg'
import { getPositionOption } from '@/api/position'
import { getAd } from '@/api/ad'
export default {
  name: 'Dashboard',
  data() {
    return {
      content: '        <div style="height:100px"></div>' +
        '        <div class="title">🦈 直聘</div>\n' +
        '        <div class="title" style="text-align: right"> ——— 业内优选</div>\n' +
        '        <br>\n' +
        '        <div class="content"> 各大互联网企业均已入驻，更有大企开发组组长直接招聘</div>\n' +
        '        <br>\n' +
        '        <div class="content"> 操作方便，活跃用户高</div>\n' +
        '        <br>\n' +
        '        <div class="content"> 一键上传简历，HR 找上门</div>',
      imgs: [
        banner1,
        banner2
      ],
      searchInput: '',
      currentRole: 'adminDashboard',
      options: {
        menu: '#menu',
        anchors: ['/index/', '/index/', '/index/'],
        sectionsColor: ['#ffffff']
      },
      positionOption: [],
      activeTypeIndex: 1,
      positionList: [],
      ad: null,
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    this.loadStyle('https://unpkg.com/fullpage.js/dist/fullpage.min.css')
    getPositionOption().then(res => { this.positionOption = res.data.items })
    getAd('index_1').then(
      res => {
        this.ad = res.data.items
      })
  },
  methods: {
    afterLoad() {
      console.log("Emitted 'after load' event.")
    },
    loadStyle(url) {
      const link = document.createElement('link')
      link.type = 'text/css'
      link.rel = 'stylesheet'
      link.href = url
      const head = document.getElementsByTagName('head')[0]
      head.appendChild(link)
    },
    wander() {
      this.$refs.fullpage.api.moveSectionDown()
    },
    toSearch() {
      // this.$refs.fullpage.api.moveSectionUp()
      this.$refs.fullpage.api.moveTo(1)
    },
    toSearchWithParam(type, pos) {
      this.$router.push({ path: '/index/search/' + type + '?type=' + type + '&position=' + pos })
    },
    toSearchPage(type) {
      this.$router.push({ path: '/index/search/' + type + '?keyword=' + this.searchInput })
    }
  }
}
</script>
<style lang="scss">
  .section{
    margin-top: 10px
  }
  .section-item{
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .carousel{
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 20px auto;
    width: 80%;
    //&:before {
    //  content: "123";
    //  position: absolute;
    //  left: calc(10vw + 5px);
    //  top: 25px;
    //  border: 4px #f7ff00 solid;
    //  border-right: none;
    //  border-bottom: none;
    //  width: 60%*0.8;
    //  height: 500px;
    //}
    .el-carousel{
      border: 2px #15e09c solid;
      border-right: none;
      border-bottom: none;
      height: 502px;
      width: 60%;
      div{
        color: #475669;
        font-size: 18px;
        //opacity: 0.75;
        line-height: 300px;
        margin: 0;
      }
      .el-carousel__container{
        height: 500px;
      }
      &:nth-child(2n) {
        background-color: #99a9bf;
      }

      &:nth-child(2n+1) {
        background-color: #d3dce6;
      }
    }
    .label{
      height: 500px;
      width: 40%;
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
      padding: 20px;
      color: #4b6649;
      .title {
        font-size: 30px;
        font-weight: bolder;
      }
      .content {
        font-size: 20px;
        font-weight: bold;
      }
    }
  }
  .search-bar {
    margin: 0 auto;
    width: 80%;
    min-width: 700px;
    height: 200px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    input {
      font-size: 20px;
      color: #7ba195;
      padding: 0 10px;
      outline:none;
      width: 500px;
      height: 50px;
      border: 2px solid #1a9b70;
      border-right: none;
      border-radius: 5px 0 0 5px;
      &:focus {
      }
    }
    .search-bar-button{
      height: 50px;
      width: 180px;
      border-radius: 0 5px 5px 0;
      font-size: 20px;
    }
  }
  .more{
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #a1b39e;
    font-size: 10px;
    span {
      cursor: pointer;
    }
    .more-icon{
      cursor: pointer;
      height: 50px;
      width: 80px;
      fill: #a1b39e;
    }
  }
  .search-keyword{
    width: 600px;
    height: 550px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
    .title{
      font-weight: bolder;
      margin-bottom: 20px;
    }
    .nav-menu{
      width: 150px;
    }
    .search-keyword-content{
      display: flex;
      align-items: flex-start;
      padding: 10px;
      margin-top: 10px;
      height: 40px;
      flex-wrap: nowrap;
      overflow: hidden;
      width: calc(100%);
      .tag{
        margin-left: 20px;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        &:hover{
          background-color: #dceee8;
          cursor: pointer;
        }
        &:active{
          background-color: #c4d7d1;
        }
      }
    }
  }
  .advertisement{
    display: flex;
    padding: 20px;
    justify-content: flex-start;
    align-items: center;
    width: calc(100% - 620px);
    height: 600px;
    margin-left: 20px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
    font-size: 40px;
    font-weight: bolder;
  }
</style>
